# 安装 Web 服务器 (IIS) 角色及指定功能
Install-WindowsFeature -Name Web-Server -IncludeManagementTools -IncludeAllSubFeature

# 安装额外的 IIS 功能
$features = @(
    "Web-Common-Http",
    "Web-Default-Doc",
    "Web-Dir-Browsing",
    "Web-Http-Errors",
    "Web-Static-Content",
    "Web-Http-Redirect",
    "Web-Health",
    "Web-Http-Logging",
    "Web-Log-Libraries",
    "Web-Request-Monitor",
    "Web-Http-Tracing",
    "Web-Performance",
    "Web-Stat-Compression",
    "Web-Dyn-Compression",
    "Web-Security",
    "Web-Filtering",
    "Web-Basic-Auth",
    "Web-CertProvider",
    "Web-IP-Security",
    "Web-Url-Auth",
    "Web-Windows-Auth",
    "Web-App-Dev",
    "Web-Net-Ext",
    "Web-Net-Ext45",
    "Web-ASP",
    "Web-Asp-Net",
    "Web-Asp-Net45",
    "Web-ISAPI-Ext",
    "Web-ISAPI-Filter",
    "Web-Includes",
    "Web-Ftp-Server",
    "Web-Ftp-Service",
    "Web-Mgmt-Tools",
    "Web-Mgmt-Console",
    "Web-Mgmt-Compat",
    "Web-Metabase",
    "Web-Lgcy-Mgmt-Console",
    "Web-Lgcy-Scripting",
    "Web-WMI",
    "Web-Scripting-Tools",
    "Web-Mgmt-Service"
)

foreach ($feature in $features) {
    Install-WindowsFeature -Name $feature
}

# 重启 IIS 服务
Restart-Service W3SVC

Write-Host "IIS 安装和配置完成。"